<template>
{{msg}}
</template>

<script>
import {error, success} from "../../utils/message";
import {BindQQ} from "../../api/user";

export default {
  name: "BindQQ",
  data(){
    return {
      msg:'正在绑定...'
    }
  },
  methods:{
    getInfo: function (){
      if (QC.Login.check()){
        const vm = this;
        success('已成功获取数据')
        QC.Login.getMe(function (openId, accessToken) {
          vm.doBind(openId)
        })
      }else {
        console.log("登录失败");
      }
    },
    doBind:async function (token) {
      const vm = this;
      let resp = await BindQQ(token)
      if(resp.code == 200){
        success(resp.message)
        vm.$router.push('/user/index')
      }else{
        error(resp.message)
      }
    }
  },
  mounted() {
    this.$nextTick(function (){
      this.getInfo()
    })
  }
}
</script>

<style scoped>

</style>